﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using KAImage.Config;

namespace IPCPhotoEditor.ChildForms
{
    public partial class FormFolderSetting : Form
    {
        BrowseOption _option = new BrowseOption();

        public FormFolderSetting()
        {
            _option = KAConfigs.Browse;
            InitializeComponent();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(textBoxFolder.Text))
            {
                MessageBox.Show("路径不存在:" + textBoxFolder.Text);
                return;
            }
            _option.DefaultBrowseFolder = textBoxFolder.Text;
            _option.Save();
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void buttonBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog form = new FolderBrowserDialog();
            form.SelectedPath = textBoxFolder.Text;
            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBoxFolder.Text = form.SelectedPath;
            }
        }

        private void FormFolderSetting_Load(object sender, EventArgs e)
        {
            textBoxFolder.Text = _option.DefaultBrowseFolder;
        }
    }
}
